Adds an OLEObject object to an OLEObjects collection.
Syntax
object.Add index, key, sourcedoc, class
The Add Method syntax has these parts:
Part | Description |
object | Required. An object expression that evaluates to an object in the Applies To list. |
index | Optional. An integer that identifies a member of the object collection. If supplied, the new member will be inserted after the member specified by the index. |
key | Optional. A unique string expression that can be used to access a member of the collection. The key and index arguments can be used interchangeably with the Item method of the collection to retrieve the OLEObject object. |
sourcedoc | Required. The filename of a document used as a template for the embedded object. The RichTextBox control doesn't support linking, so the contents of the file will be copied into the OLEObject object. Must be a zero-length string ("") if you don't specify a source document. |
class | Optional. The OLE class name for the object to be embedded. This argument is the ProgID used by OLE in the system registry. This argument is ignored if you specify a filename for sourcedoc. |
Remarks
The following code adds a Microsoft Excel worksheet to the RichTextBox and sets its Key property to "SalesData":
RichTextBox1.OLEObjects.Add , "SalesData", , "Excel.Sheet.5"
When an object is added to the collection, it immediately becomes in-place active so the user can add data to it.